home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
borland
/
svgabg52.zip
/
VGADEMO.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-09-05
|
50KB
|
1,791 lines
program BGIDemo;
{
Turbo Pascal Borland Graphics Interface (BGI) demonstration
program. This program shows how to use many features of
the Graph unit.
Copyright (c) 1985-89 by Borland International, Inc.
}
uses
Crt, Dos, Graph;
const
{ The five fonts available }
Fonts : array[0..4] of string[13] =
('DefaultFont', 'TriplexFont', 'SmallFont', 'SansSerifFont', 'GothicFont');
{ The five predefined line styles supported }
LineStyles : array[0..4] of string[9] =
('SolidLn', 'DottedLn', 'CenterLn', 'DashedLn', 'UserBitLn');
{ The twelve predefined fill styles supported }
FillStyles : array[0..11] of string[14] =
('EmptyFill', 'SolidFill', 'LineFill', 'LtSlashFill', 'SlashFill',
'BkSlashFill', 'LtBkSlashFill', 'HatchFill', 'XHatchFill',
'InterleaveFill', 'WideDotFill', 'CloseDotFill');
{ The two text directions available }
TextDirect : array[0..1] of string[8] = ('HorizDir', 'VertDir');
{ The Horizontal text justifications available }
HorizJust : array[0..2] of string[10] = ('LeftText', 'CenterText', 'RightText');
{ The vertical text justifications available }
VertJust : array[0..2] of string[10] = ('BottomText', 'CenterText', 'TopText');
var
GraphDriver : integer; { The Graphics device driver }
GraphMode : integer; { The Graphics mode value }
MaxX, MaxY : word; { The maximum resolution of the screen }
ErrorCode : integer; { Reports any graphics errors }
MaxColor : word; { The maximum color value available }
OldExitProc : Pointer; { Saves exit procedure address }
function RealDrawColor(Color : Word) : Word;
begin
if (GetMaxColor > 32768) then
SetRgbPalette(1024,(Color SHR 11) AND 31,(Color SHR 5)AND 63,Color AND 31)
else if (GetMaxColor > 256) then
SetRgbPalette(1024,(Color SHR 10) AND 31,(Color SHR 5)AND 31,Color AND 31);
RealDrawColor := Color;
end;
function RealFillColor(Color : Word) : Word;
begin
if (GetMaxColor > 32768) then
SetRgbPalette(1025,(Color SHR 11) AND 31,(Color SHR 5)AND 63,Color AND 31)
else if (GetMaxColor > 256) then
SetRgbPalette(1025,(Color SHR 10) AND 31,(Color SHR 5)AND 31,Color AND 31);
RealFillColor := Color;
end;
function RealColor(Color : Word) : Word;
begin
if (GetMaxColor > 32768) then
SetRgbPalette(1026,(Color SHR 11) AND 31,(Color SHR 5)AND 63,Color AND 31)
else if (GetMaxColor > 256) then
SetRgbPalette(1026,(Color SHR 10) AND 31,(Color SHR 5)AND 31,Color AND 31);
RealColor := Color;
end;
function WhitePixel : Word;
var Clr : Word;
begin
if (GetMaxColor > 32768) then
Clr := 65535
else if (GetMaxColor > 256) then
Clr := 32767
else
Clr := 15;
WhitePixel := Clr;
end;
function BluePixel : Word;
var Clr : Word;
begin
if (GetMaxColor > 256) then
Clr := 31
else
Clr := 1;
BluePixel := Clr;
end;
function GreenPixel : Word;
var Clr : Word;
begin
if (GetMaxColor > 32768) then
Clr := 63 SHL 5
else if (GetMaxColor > 256) then
Clr := 31 SHL 5
else
Clr := 2;
GreenPixel := Clr;
end;
{$F+}
procedure MyExitProc;
begin
ExitProc := OldExitProc; { Restore exit procedure address }
CloseGraph; { Shut down the graphics system }
end; { MyExitProc }
{$F-}
{$F+}
function DetectVGA256 : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 320x200x256');
Writeln(' 1) 640x400x256');
Writeln(' 2) 640x480x256');
Writeln(' 3) 800x600x256');
Writeln(' 4) 1024x768x256');
Writeln(' 5) 640x350x256');
Writeln(' 6) 1280x1024x256');
Write('> ');
Readln(SuggestedMode);
DetectVGA256 := SuggestedMode;
end
else
DetectVGA256 := grError; { Couldn't detect hardware }
end; { DetectVGA256 }
{$F-}
{$F+}
function DetectVGA32k : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 320x200x32k');
Writeln(' 1) 640x350x32k');
Writeln(' 2) 640x400x32k');
Writeln(' 3) 640x480x32k');
Writeln(' 4) 800x600x32k');
Writeln(' 5) 1024x768x32k');
Writeln(' 6) 1280x1024x32k');
Write('> ');
Readln(SuggestedMode);
DetectVGA32k := SuggestedMode;
end
else
DetectVGA32k := grError; { Couldn't detect hardware }
end; { DetectVGA32k }
{$F-}
{$F+}
function DetectVGA64k : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 320x200x64k');
Writeln(' 1) 640x350x64k');
Writeln(' 2) 640x400x64k');
Writeln(' 3) 640x480x64k');
Writeln(' 4) 800x600x64k');
Writeln(' 5) 1024x768x64k');
Writeln(' 6) 1280x1024x64k');
Write('> ');
Readln(SuggestedMode);
DetectVGA64k := SuggestedMode;
end
else
DetectVGA64k := grError; { Couldn't detect hardware }
end; { DetectVGA32k }
{$F-}
{$F+}
function DetectTwk256 : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) or (DetectedDriver = MCGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 320x400x256');
Writeln(' 1) 320x480x256');
Writeln(' 2) 360x480x256');
Writeln(' 3) 376x564x256');
Writeln(' 4) 400x564x256');
Writeln(' 5) 400x600x256');
Writeln(' 6) 320x240x256');
Write('> ');
Readln(SuggestedMode);
DetectTwk256 := SuggestedMode;
end
else
DetectTwk256 := grError; { Couldn't detect hardware }
end; { DetectVGA256 }
{$F-}
{$F+}
function DetectVGA16 : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = EGA) or (DetectedDriver = VGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 320x200x16');
Writeln(' 1) 640x200x16');
Writeln(' 2) 640x350x16');
Writeln(' 3) 640x480x16');
Writeln(' 4) 800x600x16');
Writeln(' 5) 1024x768x16');
Writeln(' 6) 1280x1024x16');
Write('> ');
Readln(SuggestedMode);
DetectVGA16 := SuggestedMode;
end
else
DetectVGA16 := grError; { Couldn't detect hardware }
end; { DetectVGA256 }
{$F-}
{$F+}
function DetectTwk16 : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 704x528x16');
Writeln(' 1) 720x540x16');
Writeln(' 2) 736x552x16');
Writeln(' 3) 752x564x16');
Writeln(' 4) 768x576x16');
Writeln(' 5) 784x588x16');
Writeln(' 6) 800x600x16');
Write('> ');
Readln(SuggestedMode);
DetectTwk16 := SuggestedMode;
end
else
DetectTwk16 := grError; { Couldn't detect hardware }
end; { DetectVGA256 }
{$F-}
{$F+}
function DetectText : integer;
begin
DetectText := 0;
end;
{$F-}
{$F+}
function DetectS3 : integer;
{ Detects VGA or MCGA video cards }
var
DetectedDriver : integer;
SuggestedMode : integer;
begin
DetectGraph(DetectedDriver, SuggestedMode);
if (DetectedDriver = VGA) then
begin
Writeln('Which video mode would you like to use?');
Writeln(' 0) 640x480x